package cn.dengta.webapp.push.model;

import javax.annotation.Nullable;

import org.apache.commons.lang3.ArrayUtils;

/**
 * 传播类型
 */
public enum BroadcastType {
	SINGLE,
	GROUP,
	ALL;

	public final int value;

	BroadcastType() {
		this.value = ordinal() + 1;
	}

	public boolean match(@Nullable Integer val) {
		return val != null && val == value;
	}

	public static BroadcastType of(@Nullable Integer val) {
		if (val != null) {
			return ArrayUtils.get(values(), val - 1, null);
		}
		return null;
	}

}
